<template>
  <div>
    <h3>欢迎光临_vue开发的收银系统_水果店</h3>
    <div class="box">苹果10￥/斤,折扣《8折》</div>
    <div class="box">
      请输入你要购买的斤数：<input type="number" v-model="num" />
    </div>
    <div class="box"><button @click="pay">结账买单~</button></div>
    <div class="box">
      结账单:总价{{ total }}￥ 折后价:{{ discount }}￥ 省了:{{ save }}￥
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data() {
    return {
      num: "",
      total: "",
      discount: "",
      save: "",
      zhe: 0.8,
      yuan: 10,
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    pay() {
      this.total = this.num * this.yuan;
      this.discount = this.num * this.yuan * this.zhe;
      this.save = Math.round(this.num * this.yuan * (1 - this.zhe));
    },
  },
};
</script>

<style scoped>
.box {
  width: 600px;
  height: 30px;
  border: 2px solid #000;
  text-align: center;
  line-height: 30px;
}
</style>
